$(function(){
	var d = new Date();
	var currentYear=d.getFullYear();
	$("#year").val(currentYear);
	$('#year').datetimepicker({
		startView: 4,
		minView:4,
		autoclose : true,
		format : 'yyyy'
	});
	
	$("#yearAnalysis").val(currentYear);
	$('#yearAnalysis').datetimepicker({
		startView: 4,
		minView:4,
		autoclose : true,
		format : 'yyyy'
	});
	
	$("#updateYear").val(currentYear);
	$('#updateYear').datetimepicker({
		startView: 4,
		minView:4,
		autoclose : true,
		format : 'yyyy'
	});
	
	$("#stationUpdateYear").val(currentYear);
	$('#stationUpdateYear').datetimepicker({
		startView: 4,
		minView:4,
		autoclose : true,
		format : 'yyyy'
	});
	getTableScrollHeight();
});

function getTableScrollHeight(){
	var toolBarH = 0; // toolBar的div的高度
	var tabH = toolBarH = parseInt($("#deviceRelateTab").css("height"));
	var columnH = 40;// dataTable表头的行高
	var paginatorH = 28;// dataTable分页的高度
	// 操作栏div的高度
	if (document.getElementById("toolbarDiv")) {
		toolBarH = parseInt($("#toolbarDiv").css("height"));
	} else {
		toolBarH = 0;
	}
	// 分页部分整体偏移15px，为滚动条预留位置
	$(".ui-paginator.ui-paginator-bottom").css({
		"border-top" : "0 none",
		"margin-left" : "0px",
		"margin-right" : "15px"
	});
	// 获得content的高度,10是padding
	var contentH = parseInt($("#main_content>.content").css("height")) - 120;
	var dataTableH = contentH - paginatorH - tabH; 
	document.getElementById("form:dataTb").style.maxHeight = dataTableH + "px";
	document.getElementById("form:dataTb").style.minHeight = dataTableH + "px";
	// dataTable的滚动区域高度
	var dataTableScrollH = dataTableH - columnH;
	document.getElementsByClassName("ui-datatable-scrollable-body")[0].style.maxHeight = dataTableScrollH
			+ "px";
	document.getElementsByClassName("ui-datatable-scrollable-body")[0].style.minHeight = dataTableScrollH
			+ "px";
	/* 解决当数据无法撑满整个表格的时候，没有垂直滚动条导致数据列与表头不对齐的问题 */
	document.getElementsByClassName("ui-datatable-scrollable-body")[0].style.overflowY = "scroll";
}

function chaneYear(){
	var year=$("#year").val();
	changeYear([ {
		name : 'year',
		value : year
	}]);
}
function chaneYearAnalysis(){
	var year=$("#yearAnalysis").val();
	changeYearAnalysis([ {
		name : 'yearAnalysis',
		value : year
	}]);
}

function changeUpdateYear(){
	var year=$("#updateYear").val();
	console.log(year);
	updateYear([ {
		name : 'year',
		value : year
	}]);
}

function changeStationUploadYear(){
	var year=$("#stationUpdateYear").val();
	console.log(year);
	updateYear([ {
		name : 'year',
		value : year
	}]);
}

